const fs = require('fs');
const path = require('path');
const officegen = require('officegen');
const Utils = require('./uitls');

const parseExcel = require('./parseExcel');

// 清空文件夹
Utils.clearDirSync(path.resolve(__dirname, '../output/'), 'docx');

const out = fs.createWriteStream(path.resolve(__dirname, '../output/out.docx'));

// parseExcel.readSyncXlsx();


const table = [

    [1, 'All grown-ups were once children', ''],
    [
        2,
        'there is no harm in putting off a piece of work until another day.',
        ''
    ],
    [
        3,
        'But when it is a matter of baobabs, that always means a catastrophe.',
        ''
    ],
    [4, 'You can include CR-LF inline\r\nfor multiple lines.', ''],
    [5, ['Or you can provide lines within', 'a cell in an array'], ''],
    [
        6,
        'But when it is a matter of baobabs, that always means a catastrophe.',
        ''
    ],
    [
        7,
        'watch out for the baobabs!',
        'END'
    ],
];

const tableStyle = {
    tableColWidth: 3000,
    tableSize: 24,
    tableColor: 'ada',
    tableAlign: 'left',
    tableFontFamily: 'Comic Sans MS',
    spacingBefor: 120, // default is 100
    spacingAfter: 120, // default is 100
    spacingLine: 240, // default is 240
    spacingLineRule: 'atLeast', // default is atLeast
    indent: 100, // table indent, default is 0
    fixedLayout: true, // default is false
    borders: true, // default is false. if true, default border size is 4
    // To use this option, the 'borders' must set as true, default is 4
    borderSize: 2,
    columns: [{width: 3000}, {width: 1}, {width: 42}], // Table logical columns
};

const docx = officegen('docx');
docx.createTable(table, tableStyle);


docx.generate(out);
